import { defineStore } from "pinia";
import store from "@/store";
import Cookies from "js-cookie";

export const usePermissionStore = defineStore("permission-route", {
  state: () => {
    return {
      cookies: <any>null,
    };
  },
  getters: {
    getCookies(state) {
      return state.cookies;
    },
  },
  actions: {
    setCookies() {
      let cookies = Cookies.get("sessionId");
      this.cookies = cookies;
    },
    clearCookies() {
      Cookies.remove("sessionId");
      this.cookies = null;
    },
  },
});

export default function usePermissionStoreHook() {
  return usePermissionStore(store);
}
